package com.heba.utils;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

import androidx.core.app.NotificationManagerCompat;

/**
 * 判断是否允许推送设置
 * Created by jason on 2019/3/25.
 */

public class NotificationUtils {

    /**
     * 判断是否允许推送
     *
     * @param context
     * @return
     */
    public static boolean checkNotificationEnable(Context context) {
        NotificationManagerCompat notification = NotificationManagerCompat.from(context);
        boolean isEnabled = notification.areNotificationsEnabled();
        return isEnabled;
    }

    /**
     * 跳转系统应用设置
     *
     * @param context
     */
    public static void goNotificationSettings(Context context) {
        Intent intent = new Intent();
        intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setData(Uri.parse("package:" + context.getPackageName()));
        context.startActivity(intent);
    }

}
